/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author NgocHuy
 */
public class DB_Util {
    public static Connection getConnection()
    {
        Connection cn = null;
        try {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
                //step 2
                String url;
            url = "jdbc:sqlserver://localhost:1433;databaseName=PLMSDB";
                String username = "nghia";
                String password = "1234";
                cn = DriverManager.getConnection(url,username,password);
        } catch (SQLException ex) {
            Logger.getLogger(DB_Util.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(DB_Util.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(DB_Util.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(DB_Util.class.getName()).log(Level.SEVERE, null, ex);
        }
        return cn;
    }
}
